﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ArgusLib.Threading.Collections
{
	public class SynchronizedEnumerableWrapper<T> : SynchronizedEnumerableBase<T>
	{
		IEnumerable<T> enumerable;

		public SynchronizedEnumerableWrapper(IEnumerable<T> enumerable)
			: this(enumerable, new object()) { }

		public SynchronizedEnumerableWrapper(IEnumerable<T> enumerable, object syncRoot)
			: base(syncRoot)
		{
			this.enumerable = enumerable;
		}

		protected override ISynchronizedEnumerator<T> GetEnumeratorCore()
		{
			return new SynchronizedEnumeratorWrapper<T>(this.enumerable.GetEnumerator(), this.SyncRoot);
		}
	}
}
